﻿namespace Md.Im.Service;

public class ImHelper
{
	static ImClient _instance;

	public static ImClient Instance => _instance ?? throw new Exception("使用前请初始化 ImHelper.Initialization(...);");

	public static void Initialization(ImClientOptions options)
	{
		_instance = new ImClient(options);
	}


	public static string PrevConnectServer(Guid clientId, int userId, string clientMetaData) => Instance.PrevConnectServer(clientId, userId, clientMetaData);

	public static void EventBus(Action<(Guid clientId, string clientMetaData)> onLine, Action<(Guid clientId, string clientMetaData)> offLine) => Instance.EventBus(onLine, offLine);

	public static void SendMessage(Guid senderClientId, IEnumerable<Guid> receiveClientId, object message, bool receipt = false) => Instance.SendMessage(senderClientId, receiveClientId, message, receipt);

	public static void SendChanMessage(Guid senderClientId, string chan, object message) => Instance.SendChanMessage(senderClientId, chan, message);

    public static IEnumerable<Guid> GetClientListByOnLine() => Instance.GetClientListByOnline();

	public static void JoinChan(Guid clientId, string chan) => Instance.JoinChan(clientId, chan);
}

